#Title: String Handling
#Authors: Ricardo Padilla, Alexandra Neumann
#Description: Converts uppercase string to lowercase

############# Data Segment ###################
.data
string: .asciiz "ABCDEFG"
lc_string: .asciiz ""

############# Code Segment ###################
.text
.globl main
main:
	#Load address of string to access individual characters (bytes)
	la $s0, string
	lb $t0, 0($s0)
	add $t0, $t0, 0x20 #Make A lowercase

	lb $t1, 1($s0)
	add $t1, $t1, 0x20 #Make B lowercase
	sll $t1, $t1, 8
	or $t0, $t0, $t1 #Append ab

	lb $t1, 2($s0)
	add $t1, $t1, 0x20 #Make C lowercase
	sll $t1, $t1, 16
	or $t0, $t0, $t1 #Append abc

	lb $t1, 3($s0)
	add $t1, $t1, 0x20 #Make D lowercase
	sll $t1, $t1, 24
	or $t0, $t0, $t1 #Append abcd

	la $s1, lc_string
	sw $t0, 0($s1) #Store word "abcd" into lc_string in memory

	lb $t2, 4($s0)
	add $t2, $t2, 0x20 #Make E lowercase

	lb $t1, 5($s0)
	add $t1, $t1, 0x20 #Make F lowercase
	sll $t1, $t1, 8
	or $t2, $t2, $t1 #Append ef

	lb $t1, 6($s0)
	add $t1, $t1, 0x20 #Make G lowercase
	sll $t1, $t1, 16
	or $t2, $t2, $t1 #Append efg

	sw $t2, 4($s1) #Store word "efg" into lc_string in memory
	
	#Print out lc_string
	add $a0, $s1, $zero 
	li $v0, 4
	syscall

	#Exit program
	li $v0, 10
	syscall